import { useMemo, useState } from 'react';

function useMemoTest() {
  const [ count, setCount ] = useState(0);
  const result = useMemo(() => {
    console.log('执行计算');
    return count * 2;
  }, [count]);
  const [ bool, setBool ] = useState(false);
  return (
    <div>
      <span>{count}</span>
      <button onClick={() => setCount(count + 1)}>+1</button>
      <span>{result}</span>
      <p>{bool ? '真': '假'}</p>
      <button onClick={() => setBool(!bool)}>设置bool</button>
    </div>
  );
} 

export default useMemoTest;
